//
//  WebViewController.m
//  NiuBanJinGold
//
//  Created by zf on 15/10/12.
//  Copyright © 2015年 zzjr. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()<UIWebViewDelegate>
@property (nonatomic , strong) NSArray *array_text;
@property (nonatomic , strong) NSArray *array_url;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.array_text = @[@"注册与登录" , @"存入类" , @"转出类" , @"安全类" , @"牛板金介绍" ,@"联系我们" , @"" , @"安全保障" , @"活动中心" , @"加息券获取方法和使用规则" , @"牛板金服务协议" , @"签到规则" , @"积分规则" ];
   
    self.navigationItem.title = [self.array_text objectAtIndex:self.index];
    
    NSLog(@"%@",self.navigationItem.title);
    UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGestureAction)];
    [self.view addGestureRecognizer:swipeGesture];
        // 加息券获取方法和使用规则
    NSURL *url_COUPON_RULES = [NSURL URLWithString:@"http://style.niubangold.com/app/coupon_rules.app.html"];
    // 安全保障
    NSURL *url_SECURITY_DESCRIPTION = [NSURL URLWithString:@"http://style.niubangold.com/app/security_measures.app.html"];
    // 活动中心
//    NSURL *url_ACTIVITY = [NSURL URLWithString:@"http://style.niubangold.com/app/activity.html"];
    
    NSURL *url_ACTIVITY =  nil;
    
    if (self.activity_url) {
        
        url_ACTIVITY = [NSURL URLWithString:self.activity_url];
        
    }else {
        url_ACTIVITY = [NSURL URLWithString:@"http://style.niubangold.com/app/activity.html"];
    }
    // 牛板金介绍
     NSURL *url_about = [NSURL URLWithString:@"http://style.niubangold.com/app/about.app.html"];
    // 关于我们
    NSURL *url_ABOUT = [NSURL URLWithString:@"http://style.niubangold.com/app/about.html"];
    // 联系我们
     NSURL *url_CONTACT_HTML = [NSURL URLWithString:@"http://style.niubangold.com/app/contact.app.html"];
    // 《牛板金服务协议》
    NSURL *url_AGREEMENT = [NSURL URLWithString:@"http://style.niubangold.com/app/nbj_services_agreement.app.html"];
    // 注册登录帮助
    NSURL *url_HELP_LOGIN = [NSURL URLWithString:@"http://style.niubangold.com/app/help_login.app.html"];
    // 存入帮助
     NSURL *url_HELP_DEPOSIT = [NSURL URLWithString:@"http://style.niubangold.com/app/help_deposit.app.html"];
    // 转出帮助
     NSURL *url_HELP_WITHDRAW = [NSURL URLWithString:@"http://style.niubangold.com/app/help_withdraw.app.html"];
    // 安全帮助
     NSURL *url_HELP_SECURITY = [NSURL URLWithString:@"http://style.niubangold.com/app/help_security.app.html"];
    // 签到规则
    NSURL *url_SIGN_IN_RULES = [NSURL URLWithString:@"http://style.niubangold.com/app/sign_in_rules.app.html"];
    //积分规则
     NSURL *url_points_rules = [NSURL URLWithString:@"http://style.niubangold.com/app/points_rules.app.html"];
     NSDictionary *dic_url = @{@"注册与登录" :url_HELP_LOGIN, @"存入类" : url_HELP_DEPOSIT, @"转出类" : url_HELP_WITHDRAW, @"安全类" : url_HELP_SECURITY , @"牛板金介绍" :url_about  ,@"关于我们" : url_ABOUT ,  @"安全保障" : url_SECURITY_DESCRIPTION, @"活动中心" : url_ACTIVITY , @"加息券获取方法和使用规则" : url_COUPON_RULES, @"牛板金服务协议" : url_AGREEMENT, @"签到规则" :url_SIGN_IN_RULES ,@"联系我们" : url_CONTACT_HTML , @"积分规则" : url_points_rules};
  
    UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - MULTIPLYHEIGHT(60.0))];
    [webView setScalesPageToFit:YES];
    webView.delegate = self;
    [self.view addSubview:webView];
    
    if (dic_url[self.navigationItem.title]) {
        
        [MBProgressHUD showHUDAddedTo:webView animated:YES];
//        NSURLRequest *request = [NSURLRequest requestWithURL:dic_url[self.navigationItem.title]];
        NSURLRequest  *request = [NSURLRequest requestWithURL:dic_url[self.navigationItem.title] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:6];
        [webView loadRequest:request];
    }
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
    [MBProgressHUD hideAllHUDsForView:webView animated:YES];
}
#pragma mark -swipeGestureAction
-(void)swipeGestureAction{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
